@extends("layout.admin")

@section("title")
    考场设置
@endsection

@section("content")
    <style>
        .help-block {
            display: block;
            margin-top: 5px;
            margin-bottom: 10px;
            color: #737373;
        }
        .layui-form-label{
            width: 150px !important;
        }
    </style>
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-brief">
            <div><h3>考场名称：{{$basic}}</h3></div>
            <hr />
            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <form  style="margin-top: 15px;" class="layui-form" action="{{route('admin.basic.setting')}}">
                        @csrf
                        <div class="layui-form-item">
                            <label class="layui-form-label">试卷</label>
                            <div class="layui-col-xs4" style="width: 540px;">
                                <input type="hidden" name="id" value="{{$res['id']}}" />
                                <input type="hidden" name="basic_id" value="{{request('basic_id')}}">
                                <input type="text" value="{{$res['exam_paper']}}" name="exam_paper" class="layui-input" placeholder="请选择试卷">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">试卷模版</label>
                            <div class="layui-col-xs4" style="width: 540px;">
                                <select name="templet">
                                    <option value="">请选择试卷模版</option>
                                    @foreach($templet as $vo)
                                    <option value="{{$vo['value']}}" @if($vo['value'] == $res['templet'])selected="selected"@endif>{{$vo['name']}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">允许考试次数</label>
                            <div class="layui-col-xs4" style="width: 540px;">
                                <input type="number" value="{{$res['exam_times']}}" name="exam_times" class="layui-input" placeholder="请输入考试次数">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">考场开放时间</label>
                            <div class="layui-inline" id="test6">
                                <div class="layui-input-inline">
                                    <input type="text" name="open_start_at" id="open_start_at" value="{{$res['open_start_at']}}" placeholder="请选择考场开放开始时间"
                                           class="layui-input">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline">
                                    <input type="text" name="open_end_at" id="open_end_at" value="{{$res['open_end_at']}}" placeholder="请选择考场开放结束时间"
                                           class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">交卷后是否显示成绩</label>
                            <div class="layui-col-xs4" style="width: 540px;">
                                <input type="radio" name="view_score" value="0" title="否" @if($res['view_score'] == 0)checked=""@endif>
                                <input type="radio" name="view_score" value="1" title="是" @if($res['view_score'] == 1)checked=""@endif>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" lay-submit lay-filter="*">提交</button>
                                <a href="{{route('admin.basic.index')}}" class="layui-btn layui-btn-primary">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
@endsection
@section('script')
    <script src="{{asset('layui/modules/xm-select.js')}}"></script>
    <script src="{{asset('js/tree/select.js')}}"></script>
    <script>
        var idx = -1;
        layui.use(['form','table','xmSelect'], function () {
            var table = layui.table;
            var form = layui.form,xmSelect = layui.xmSelect;
            var laydate = layui.laydate;
            laydate.render({
                elem: '#open_start_at'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '#open_end_at'
                ,type: 'datetime'
            });
            table.init("table-hide");
            form.on("submit(*)", function (data) {
                var obj = $(this);
                //obj.attr("disabled", "disabled").addClass("layui-disabled");
                $.post(data.form.action, data.field, function (data) {
                    var icon = 5;
                    if (data.code == "0") {
                        icon = 6;
                    }
                    layer.msg(data.msg, {icon: icon, time: 1500}, function () {   //提示的插件，可以使用alert代替
                        if (data.code==0) {
                            setTimeout(function () {
                                //刷新父页面
                                window.location.reload();
                            }, 500);
                        } else {
                            obj.removeAttr("disabled").removeClass("layui-disabled");
                        }
                    });
                }, 'json');
                return false;
            });
        });
    </script>
@endsection
